﻿#region Copyright Notice
// 
// 
// Copyright (c) 2009-2010 Anindya Chatterjee
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// 
// 
// 
#endregion
using System;
using System.Net;
using System.Xml.Serialization;
using ComponentFactory.Krypton.Toolkit;

namespace Event.Plugin.Configuration
{
    /// <summary>
    /// Ozone application configurations
    /// </summary>
    public class AppConfig : XObject, ISettings
    {
        /// <summary>
        /// Gets or sets a value indicating whether [use proxy].
        /// </summary>
        /// <value><c>true</c> if [use proxy]; otherwise, <c>false</c>.</value>
        public bool UseProxy { get; set; }

        /// <summary>
        /// Gets or sets the proxy.
        /// </summary>
        /// <value>The proxy.</value>
        [XmlElement(Type = typeof (WebProxySettings))]
        public WebProxy Proxy { get; set; }

        /// <summary>
        /// Gets or sets the first run time.
        /// </summary>
        /// <value>The first run time.</value>
        public DateTime FirstRun { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to run ozone in [safe mode].
        /// </summary>
        /// <value><c>true</c> if [safe mode]; otherwise, <c>false</c>.</value>
        public bool SafeMode { get; set; }

        /// <summary>
        /// Gets or sets a value indiicating whether it should automatically check for update or not.
        /// </summary>
        /// <value><c>true</c> if [automatic update]; otherwise, <c>false</c>.</value>
        public bool AutomaticUpdate { get; set; }

        /// <summary>
        /// Gets or sets a value which determines the theme of the application.
        /// </summary>
        public PaletteModeManager Theme { get; set; }

        /// <summary>
        /// Gets or sets a value which determines whether feedback is given or not.
        /// </summary>
        public bool FeedBackGiven { get; set; }

        /// <summary>
        /// Gets or sets a value which determines whether donation is given or not.
        /// </summary>
        public bool DonationGiven { get; set; }

        /// <summary>
        /// Executes routines just before serialization
        /// </summary>
        public override void Close()
        {
            base.Close();
            if (DateTime.Compare(FirstRun, DateTime.MinValue) <= 0)
                FirstRun = DateTime.Now;
        }
    }
}